home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dr. Windows 3
/
dr win3.zip
/
dr win3
/
PROGRAMR
/
FLAT.ZIP
/
FLATADD.C
< prev
next >
Wrap
C/C++ Source or Header
|
1993-06-21
|
12KB
|
341 lines
#define WIN31
#include <windows.h>
/* For the fancy looking Borland dialog box routines */
#ifdef USES_BWCC
#include <bwcc.h>
#endif
#include "flatm.h"
#pragma hdrstop
#include "flatadd.h"
#include "flatdata.h"
#include <dos.h>
#include <stdlib.h>
#include <ctype.h>
#ifdef USES_MEMCHECK
/* Memory checking routines by StratosWare Corp. */
#include "\wmemchec\memcheck.h"
#endif
/*--------------------------------------------
-
- FLATADD.C for Flat Windows Program
-
- Use a editing dialog box to add, edit
- display, or delete a data record
-
- Dennis R. Fischer
- Denam Systems
- 1115 Madison St. NE Suite 226
- Salem, Oregon 97303
-
- CompuServe 70405,1422
- Internet 70405.1422@compuserve.com
-
- Developed with Borland 3.1 Compiler
-
- Free for the taking but please give credit
- where credit is do
-
----------------------------------------------*/
#define SetPushButton(hDlg, idControl) \
PostMessage(GetDlgItem(hDlg, idControl), BM_SETSTYLE, BS_PUSHBUTTON, 1L);
#define SetDefPushButton(hDlg, idControl) \
PostMessage(GetDlgItem(hDlg, idControl), BM_SETSTYLE, BS_DEFPUSHBUTTON, 1L);
BOOL CALLBACK _export ProcessSaleProc(HWND, UINT, WPARAM, LPARAM);
BOOL ProcessSale(HWND hW)
{
/* Create a dialog box */
FARPROC fpAdd;
BOOL bUseIt;
fpAdd = MakeProcInstance(ProcessSaleProc, GetInstance());
if (fpAdd) {
bUseIt = DialogBox(GetInstance(), "DLG_ADD", hW, fpAdd);
FreeProcInstance(fpAdd);
}
return bUseIt;
} /* ProcessSale */
#pragma argsused
BOOL CALLBACK _export ProcessSaleProc(HWND hDlg,
UINT message,
WPARAM wParam,
LPARAM lParam) {
struct date dt;
char ts[41];
char ts2[6];
switch(message) {
case WM_INITDIALOG:
switch (GetWork()) {
case DoEdit : SetWindowText(hDlg, "Edit Sales"); break;
case DoNew : SetWindowText(hDlg, "New Sale"); break;
case DoDelete:
case DoView : if (GetWork() == DoView) {
SetWindowText(hDlg, "View Sales");
EnableWindow(GetDlgItem(hDlg, IDOK), FALSE);
}
else {
SetWindowText(hDlg, "Delete Sale");
SetPushButton(hDlg, IDOK);
SetDefPushButton(hDlg, IDCANCEL);
EnableWindow(GetDlgItem(hDlg, IDOK), TRUE);
}
/* turn off all editing fields so
user can't tamper with them
*/
EnableWindow(GetDlgItem(hDlg, DLG_INVOICE), FALSE);
EnableWindow(GetDlgItem(hDlg, DLG_COMPANY), FALSE);
EnableWindow(GetDlgItem(hDlg, DLG_NAME), FALSE);
EnableWindow(GetDlgItem(hDlg, DLG_ADDRESS1), FALSE);
EnableWindow(GetDlgItem(hDlg, DLG_ADDRESS2), FALSE);
EnableWindow(GetDlgItem(hDlg, DLG_CITY), FALSE);
EnableWindow(GetDlgItem(hDlg, DLG_STATE), FALSE);
EnableWindow(GetDlgItem(hDlg, DLG_ZIP), FALSE);
EnableWindow(GetDlgItem(hDlg, DLG_COUNTRY), FALSE);
EnableWindow(GetDlgItem(hDlg, DLG_PRODUCT), FALSE);
EnableWindow(GetDlgItem(hDlg, DLG_PRICE), FALSE);
EnableWindow(GetDlgItem(hDlg, DLG_SOLDVERSION), FALSE);
EnableWindow(GetDlgItem(hDlg, DLG_UPDATEVERSION), FALSE);
EnableWindow(GetDlgItem(hDlg, DLG_DATEINPUT1), FALSE);
EnableWindow(GetDlgItem(hDlg, DLG_DATEINPUT2), FALSE);
EnableWindow(GetDlgItem(hDlg, DLG_DATEINPUT3), FALSE);
break;
default : SetWindowText(hDlg, "Error"); break;
}
switch (GetWork()) {
case DoNew :
/* system date */
getdate(&dt);
/* Make sure input boxes are clear */
SetDlgItemText(hDlg, DLG_INVOICE, "");
SetDlgItemText(hDlg, DLG_NAME, "");
SetDlgItemText(hDlg, DLG_COMPANY, "");
SetDlgItemText(hDlg, DLG_ADDRESS1, "");
SetDlgItemText(hDlg, DLG_ADDRESS2, "");
SetDlgItemText(hDlg, DLG_CITY, "");
SetDlgItemText(hDlg, DLG_STATE, "");
SetDlgItemText(hDlg, DLG_ZIP, "");
SetDlgItemText(hDlg, DLG_COUNTRY, "USA");
/* You can put your default info here */
SetDlgItemText(hDlg, DLG_PRODUCT, "Nag");
SetDlgItemText(hDlg, DLG_PRICE, "20.00");
SetDlgItemText(hDlg, DLG_SOLDVERSION, "");
SetDlgItemText(hDlg, DLG_UPDATEVERSION, "");
itoa(dt.da_mon, ts, 10);
SetDlgItemText(hDlg, DLG_DATEINPUT1, ts);
itoa(dt.da_day, ts, 10);
SetDlgItemText(hDlg, DLG_DATEINPUT2, ts);
itoa(dt.da_year, ts, 10);
SetDlgItemText(hDlg, DLG_DATEINPUT3, ts);
break;
default:
/* If editing, viewing, or deleting a
data record, load the dialog box editing
fields with the record info
*/
ts[0]=(char)0;
GetInvoice(ts);
SetDlgItemText(hDlg, DLG_INVOICE, ts);
ts[0]=(char)0;
GetName(ts);
SetDlgItemText(hDlg, DLG_NAME, ts);
ts[0]=(char)0;
GetCompany(ts);
SetDlgItemText(hDlg, DLG_COMPANY, ts);
ts[0]=(char)0;
GetAddress1(ts);
SetDlgItemText(hDlg, DLG_ADDRESS1, ts);
ts[0]=(char)0;
GetAddress2(ts);
SetDlgItemText(hDlg, DLG_ADDRESS2, ts);
ts[0]=(char)0;
GetCity(ts);
SetDlgItemText(hDlg, DLG_CITY, ts);
ts[0]=(char)0;
GetState(ts);
SetDlgItemText(hDlg, DLG_STATE, ts);
ts[0]=(char)0;
GetZip(ts);
SetDlgItemText(hDlg, DLG_ZIP, ts);
ts[0]=(char)0;
GetCountry(ts);
SetDlgItemText(hDlg, DLG_COUNTRY, ts);
ts[0]=(char)0;
GetProduct(ts);
SetDlgItemText(hDlg, DLG_PRODUCT, ts);
ts[0]=(char)0;
GetPriceDollar(ts);
lstrcat(ts, ".");
GetPriceCent(ts);
SetDlgItemText(hDlg, DLG_PRICE, ts);
ts[0]=(char)0;
GetSoldVersion(ts);
SetDlgItemText(hDlg, DLG_SOLDVERSION, ts);
ts[0]=(char)0;
GetUpdateVersion(ts);
SetDlgItemText(hDlg, DLG_UPDATEVERSION, ts);
/* Set the correct date fields by date format */
switch (GetDateFormat()){
case DayMonYear:
ts[0]=(char)0;
GetDay(ts);
SetDlgItemText(hDlg, DLG_DATEINPUT1, ts);
ts[0]=(char)0;
GetMonth(ts);
SetDlgItemText(hDlg, DLG_DATEINPUT2, ts);
ts[0]=(char)0;
GetYear(ts);
SetDlgItemText(hDlg, DLG_DATEINPUT3, ts);
break;
case YearMonDay:
ts[0]=(char)0;
GetYear(ts);
SetDlgItemText(hDlg, DLG_DATEINPUT1, ts);
ts[0]=(char)0;
GetMonth(ts);
SetDlgItemText(hDlg, DLG_DATEINPUT2, ts);
ts[0]=(char)0;
GetDay(ts);
SetDlgItemText(hDlg, DLG_DATEINPUT3, ts);
break;
default:
/* MonDayYear */
ts[0]=(char)0;
GetMonth(ts);
SetDlgItemText(hDlg, DLG_DATEINPUT1, ts);
ts[0]=(char)0;
GetDay(ts);
SetDlgItemText(hDlg, DLG_DATEINPUT2, ts);
ts[0]=(char)0;
GetYear(ts);
SetDlgItemText(hDlg, DLG_DATEINPUT3, ts);
break;
}
break;
}
/* Set the dialog box date display info for the country */
switch (GetDateFormat()) {
case DayMonYear:
SetDlgItemText(hDlg, DLG_DATESTR1, " Day");
SetDlgItemText(hDlg, DLG_DATESTR2, " Month");
SetDlgItemText(hDlg, DLG_DATESTR2, " Year");
break;
case YearMonDay:
SetDlgItemText(hDlg, DLG_DATESTR1, " Year");
SetDlgItemText(hDlg, DLG_DATESTR2, " Month");
SetDlgItemText(hDlg, DLG_DATESTR2, " Day");
break;
default:
/* MonDayYear format */
SetDlgItemText(hDlg, DLG_DATESTR1, " Month");
SetDlgItemText(hDlg, DLG_DATESTR2, " Day");
SetDlgItemText(hDlg, DLG_DATESTR2, " Year");
break;
}
/* now set the max input length */
SendDlgItemMessage(hDlg, DLG_INVOICE, EM_LIMITTEXT, 7, 0L);
SendDlgItemMessage(hDlg, DLG_NAME, EM_LIMITTEXT, 30, 0L);
SendDlgItemMessage(hDlg, DLG_COMPANY, EM_LIMITTEXT, 30, 0L);
SendDlgItemMessage(hDlg, DLG_AD